package cn.tj.student.web.servlet;

import cn.tj.student.dao.StudentDao;
import cn.tj.student.dao.impl.StudentDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求中的id
        String id =req.getParameter("id");
        StudentDao studentDao=new StudentDaoImpl();
        int row = studentDao.deleteStudent(Long.valueOf(id));
        if(row>0){
            resp.sendRedirect("/list");
        }
    }
}
